package com.dhnsoft.web.service;

import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Service;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

/**
 * @author dhn
 * @version 1.0
 * @date 2023-09-04 10:09
 * @Desc
 */
@Service
public class Aservice {

    public void a(){
        //当前请求
        ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();

        //任意位置随时通过RequestContextHolder获取当前请求和响应的信息
        HttpServletRequest request = attributes.getRequest();
        HttpServletResponse response = attributes.getResponse();


        //获取当前uri
        String requestURI = request.getRequestURI();
    }
}
